#!/usr/bin/env python3
# -*- coding: utf-8 -*-

""" 读取配置文件 """

import configparser


class Configuration:

    def __init__(self, file):
        self.config = configparser.ConfigParser()
        self.config.read(file)

    def get(self, section, key):
        return self.config.get(section, key)

    def getBoolean(self, key):
        return self.config.getboolean(key, None)

    def set(self, section, key, value):
        self.config.set(section, key, value)


if __name__ == '__main__':
    configuration = Configuration('config.ini')
    print(configuration.get('db', 'db_port'))
